commit message 应该清晰明了,说明本次提交的目的
git commit -m "message":一行 commit messagegit commit:跳出文本编辑器,可以写多行# 显示上次发布后的变动,每个 commit 占据一行
# 只看行首,就知道某次 commit 的目的
git log <last tag> HEAD --pretty=format:%s
# 仅显示本次发布新增加的功能
git log <last release> HEAD --grep feature
commit message 包括三个部分:Header、Body 和 Footer
<type>(<scope>): <subject>
# 空一行 #
<body>
# 空一行 #
<footer>
Header 只有一行,包括三个字段:type(类型)、scope(范围)和 subject(主题)
feat:新功能fix:修补 BUGrefactor:重构test:增加测试docs:文档style:代码格式,不影响代码运行的变动chore:杂活、零工,如:构建过程或辅助工具的变动change,而不是 changed 或 changes.)是对本次 commit 的详细描述,可以分成多行
范例:
More detailed explanatory text, if necessary. Wrap it to
about 72 characters or so.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Use a hanging indent
注意:
change 而不是 changed 或 changes只用于两种情况:
BREAKING CHANGE 开头,后面是对变动的描述、以及变动理由和迁移方法BREAKING CHANGE: isolate scope bindings definition has changed.
To migrate the code follow the example below:
Before:
scope: {
myAttr: 'attribute',
}
After:
scope: {
myAttr: '@',
}
The removed `inject` wasn't generaly useful for directives so there should be no code using it.
Closes #234
# 关闭多个Issue
Closes #123, #245, #992
当前 commit 用于撤销以前的 commit
revert: 开头,后面跟着被撤销 Commit 的 HeaderThis reverts commit <hash>.,其中的 hash 是被撤销 commit 的 SHA 标识符revert: feat(pencil): add 'graphiteWidth' option
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
[[001.搭建项目架构#commit 规范检查:CommitLint|commit 规范检查]]
如果所有 commit 都符合 Angular 格式,那么发布新版本时, Change log 就可以用脚本自动生成
生成的文档包括三个部分:
每个部分都会罗列相关的 commit ,并且有指向这些 commit 的链接
当然,生成的文档允许手动修改,所以发布前,还可以添加其他内容
生成 Change log 的工具:conventional-changelog
npm install -g conventional-changelog
cd my-project
# 不会覆盖以前的 Change log,只会在 CHANGELOG.md 的头部加上自从上次发布以来的变动
conventional-changelog -p angular -i CHANGELOG.md -w
# 生成所有发布的 Change log
conventional-changelog -p angular -i CHANGELOG.md -w -r 0